package com.shanyi.sendmsg.tool;

import org.springframework.stereotype.Service;

import java.awt.*;
import java.awt.event.KeyEvent;

@Service
public class RobotTool {
    public String robotSendMsg(String str) {
        try {
            Robot robot = new Robot();
            
            robot.delay(1000);
            
            SetClipboard.SetClipboard(str);
            
            robot.delay(1000);
            
            robot.keyPress(KeyEvent.VK_CONTROL);
            robot.keyPress(KeyEvent.VK_V);
            robot.keyRelease(KeyEvent.VK_V);
            robot.keyRelease(KeyEvent.VK_CONTROL);
            
            robot.delay(1000);
            
            robot.keyPress(KeyEvent.VK_ENTER);
            robot.keyRelease(KeyEvent.VK_ENTER);
            
            robot.delay(1000); 
            
        } catch (AWTException e) {
            e.printStackTrace();
        }
        
        return "success";
    }
}
